import { useState } from 'react';
import { PaginationResponse } from '@datorama/akita';

import { makeFacade, RoomsOrgFacade } from '@/facade/orgFollowFacade';
import { VISIBILITY_FILTER } from '@/models/commonType'; 
import { useObservable } from '@/utils/rxHelpers';
import { OrgsItem } from '@/models/request/userReq';

export type OrgFollowsHookTuple = [RoomsOrgFacade, PaginationResponse<OrgsItem>, VISIBILITY_FILTER];

//需要在页面用到的变量都在这里hook，主要用于简化页面调用逻辑和代码
export function useOrgFollowsFacade(): OrgFollowsHookTuple {
  const [roomsFacade] = useState(() => makeFacade());  

  const [filter] = useObservable(roomsFacade.filter$, VISIBILITY_FILTER.SHOW_ALL);

  const [pagination1] = useObservable(roomsFacade.pagination$, {} as PaginationResponse<OrgsItem>);

  return [roomsFacade, pagination1, filter];
}
